home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 05 / HexByte.java < prev    next >
Encoding:
Java Source  |  2000-09-08  |  256 b   |  7 lines

  1. class    HexByte {
  2. static public void main(String args[]) { 
  3. char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
  4. byte b = (byte) 0xf1;
  5. System.out.println("b = 0x" + hex[(b >> 4) & 0x0f] + hex[b & 0x0f]);
  6. } }
  7.